package com.example.springsecurity.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class helloController {

    @RequestMapping("/hello")
    @ResponseBody
    public String hello(){
        return "hello";
    }

    @GetMapping("/test")
    @ResponseBody
    @PreAuthorize("hasAuthority('test')")
    public String hi(){
        return "test";
    }


    @GetMapping("/list")
    @ResponseBody
    @PreAuthorize("hasAuthority('sys:book:list')")
    public String list(){
        return "列表功能";
    }

    @GetMapping("/delete")
    @ResponseBody
    @PreAuthorize("hasAuthority('sys:book:delete')")
    public String delete(){
        return "删除功能";
    }
}
